<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>06_JS函数</title>
</head>
<body>
<script>
  function f1(){
    console.log('f1被调用了')
  }
  f1();
  function f2(){
    console.log('f2被调用了！');
    console.log(n);
  }
  f2(100);//实参
  f2('你好');
  f2(true);

  //函数可以设置多个参数，如果实参与形参的个数不匹配：
  //实参个数大于形参个数，多余的参数会被忽略掉
  //实参个数小于形参个数，缺少的参数会被设置为undefined
  function f3(x,y){
    console.log('f3被调用了！');
    console.log(x+y);
  }
  f3(1,2);
  f3(10,20,30);
  f3(10); //10+undefined=NaN

  //方法的返回值
  function f4(x,y){
    console.log('f4被调用了！');
    return x+y;
  }
  console.log(f4(10,20));
  let res = f4(10,20);
  console.log(res);

  function f5(x,y){
    console.log('f5被调了！');
  }
  f5();
  console.log(typeof f5,f5);

  //箭头函数
  const f6 = () => {
    console.log('f6被调了！');
  }
  f6();


</script>
</body>
</html>